package com.haojin.haojintimingmonitor.controller;

import com.haojin.haojintimingmonitor.domain.AlarmLog;
import com.haojin.haojintimingmonitor.domain.TravelVehicle;
import com.haojin.haojintimingmonitor.config.MessageInfo;
import com.haojin.haojintimingmonitor.config.YunpianConfigInfo;
import com.haojin.haojintimingmonitor.constant.ChuangLanHomeSmsConstants;
import com.haojin.haojintimingmonitor.mapper.UserMapper;
import com.haojin.haojintimingmonitor.service.AlarmLogService;
import com.haojin.haojintimingmonitor.service.VehicleTravelService;
import com.haojin.haojintimingmonitor.utils.SmsUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author unique
 * @version 1.0
 */
@RestController
@RequestMapping("/start")
@Slf4j
public class StartController {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private  YunpianConfigInfo yunpianConfigInfo;
    @Autowired
    private VehicleTravelService vehicleTravelService;
    @Autowired
    private AlarmLogService alarmLogService;
    @Autowired
    private MessageInfo messageInfo;
    @GetMapping("/test")
    public String getTest(){
        log.info("欢迎");
        log.info(ChuangLanHomeSmsConstants.MSG);
        log.info(yunpianConfigInfo.getUrl());
        log.info(yunpianConfigInfo.getApikey());
        log.info(yunpianConfigInfo.getMobile());
        log.info(messageInfo.getApp());
        log.info(messageInfo.getTableA());
        log.info(messageInfo.getTableB());
        log.info(messageInfo.getNight().toString());
        log.info(messageInfo.getDay().toString());
        log.info(messageInfo.getMsg());
        TravelVehicle recentTravel = vehicleTravelService.getRecentTravel();
        log.info("车辆行程信息{}",recentTravel);
        AlarmLog recentAlarmLog = alarmLogService.getRecentAlarmLog();
        log.info("告警日志记录{}",recentAlarmLog);
        return "欢迎welcome!!";
    }
    @GetMapping("/message")
    public String getMessage(){

        SmsUtils.sendMessage(messageInfo.getDay(), messageInfo.getTableA(), messageInfo.getApp());
//        SmsUtils.sendMessage(messageInfo.getNight(), messageInfo.getTableB(), messageInfo.getApp());

        return "欢迎welcome!,发送短信";
    }
}
